package hibernate.administratorAccount;

import hibernate.p.Pair;
import hibernate.p.Unit;
import java.util.StringTokenizer;

public class Salary implements java.io.Serializable{
	
	private Pair monthlyPay;
	private Pair yearlyPay;
	private Employee employee;
	private Long id;
	
	public void setEmployee(Employee employee){
		this.employee=employee;
	}
	
	public Employee getEmployee(){return employee;}
	
	public void setId(Long id){this.id=id;}
	
	public Long getId(){return this.id;}
	
	public void setMonthlyPay(String info){
		StringTokenizer st=new StringTokenizer(info,"|");
		monthlyPay=new Pair(new Double(st.nextToken()),Unit.parseUnit(st.nextToken()));
	}
	
	public Double getMonthlyPay(){
		return ((Double)monthlyPay.getFirst()).doubleValue();
	}
	
	public void setMonthlyPay(Double info){
		this.yearlyPay.setFirst(info);
	}
	
	public Unit getMonthlyPayUnit(){
		return ((Unit)this.monthlyPay.getSecond());
	}
	
	public void setMonthlyPayUnit(String unit){
		this.monthlyPay.setSecond(Unit.parseUnit(unit));
	}
	
	public Double getYearlyPay(){
		return ((Double)monthlyPay.getFirst()).doubleValue();
	}
	
	public void setYearlyPay(Double info){
		this.yearlyPay.setFirst(info);
	}
	
	public Unit getYearlyPayUnit(){
		return ((Unit)this.monthlyPay.getSecond());
	}
	
	public void setYearlyPayUnit(String unit){
		this.monthlyPay.setSecond(Unit.parseUnit(unit));
	}
	
	public boolean equals(Object sry){
		if(!(sry instanceof Salary))
			return false;
		else return ((Salary)sry).id == this.id;
	}
}
